import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core';
import {DynamicComponent, DynamicComponentEvent} from '../dynamic-component/dynamic-component.interface';

@Component({
  selector: 'ng-tools-button',
  templateUrl: './button.component.html',
  styleUrls: ['./button.component.scss']
})
export class ButtonComponent implements OnInit, DynamicComponent {
  dynamic: true;
  events: DynamicComponentEvent;
  context: any;
  @Output() clicked = new EventEmitter();
  @Input() btnClass: string;
  @Input() text: string;
  @Input() iconClass: string;

  set data(values: { btnClass: string; text: string; iconClass: string }) {
    this.btnClass = values.btnClass;
    this.text = values.text;
    this.iconClass = values.iconClass;
  }

  constructor() {
  }

  ngOnInit() {
  }

  buttonClicked(e) {
    this.clicked.emit(e);
    this.events.click(e, ...this.context);
  }

}
